import React from 'react';
import ReactDOM from 'react-dom';
import getBrowserInfo from 'get-browser-info';
import 'shared/utils/rem';
import './styles/antd-mobile.css';
import Router from './routers';
import './styles/index';

const clientInfo = getBrowserInfo();

window.isMobile = clientInfo.device === "Mobile" || clientInfo.device === "Tablet"
window.__self = {}

if (process.env.NODE_ENV === 'app') {
  window._smq = {
    push: () => {}
  };
} else {
  const script = document.createElement('script');
  script.type = 'text/javascript';
  script.src = 'https://qiyukf.com/script/c843342cd9913031105315f54c05e844.js';     //填自己的js路径
  document.querySelector('body').appendChild(script)

  const script2 = document.createElement("script")
  const msg2="var _smq = _smq || [];_smq.push(['_setAccount', '4dc5978', new Date()]);_smq.push(['_setDirectoryIndex', 'index.html']);_smq.push(['pageview']);(function() {var sm = document.createElement('script'); sm.type = 'text/javascript';sm.async = true;sm.src = ('https:' == document.location.protocol ? 'https://' : 'http://')+ 'cdnmaster.com/sitemaster/collect.js';var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(sm, s);})();"
  script2.innerText=msg2
  document.getElementsByTagName('head')[0].appendChild(script2);
}

window.gloablMonitor = (params) => {
  const data = ['custom', ...params];
  _smq.push(data)
}

function loadPage() {
  ReactDOM.render(
    <Router />,
    document.getElementById('root')
  );
}

loadPage();
